import 'package:flutter/material.dart';
import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart';

class SwiperTwo extends StatefulWidget {
  const SwiperTwo({Key? key}) : super(key: key);

  @override
  State<SwiperTwo> createState() => _SwiperTwoState();
}

class _SwiperTwoState extends State<SwiperTwo> {
  List<Map> imgList=[
    {
      "url":"https://www.itying.com/images/flutter/1.png"
    },
    {
      "url":"https://www.itying.com/images/flutter/2.png"
    },
    {
      "url":"https://www.itying.com/images/flutter/3.png"
    },
     {
      "url":"https://www.itying.com/images/flutter/4.png"
    }
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar:AppBar(
        title: Text("轮播图案例2"),
      ),
      body: Column(
        children: [
          Container(
            child: AspectRatio(
              aspectRatio:16/9,
              child: Swiper(
                itemBuilder: (context, index) {
                  return Image.network(
                    imgList[index]["url"],
                    fit: BoxFit.fill,
                  );
                },
                itemCount: imgList.length,
                pagination: new SwiperPagination(),
                autoplay: true,
              ),
            ),
          ),
          Row(
            children: [
              Text("我是一个文本")
            ],
          )
        ],
      )
    );
  }
}